package com.loong.web.suppert.auth;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

/**
 * 用户信息
 *
 * @author 张成轩
 */
public class User implements Serializable {

	private static final long serialVersionUID = -1100694592965732805L;

	private Integer id;
	private String user;
	private Set<String> auths;

	/**
	 * @param id id
	 * @param user 用户
	 * @param auths 权限列表
	 */
	public User(Integer id, String user, Set<String> auths) {

		this.id = id;
		this.user = user;
		this.auths = (auths == null ? new HashSet<String>() : auths);
	}

	/**
	 * @return id
	 */
	public Integer getId() {

		return id;
	}

	/**
	 * @return 用户
	 */
	public String getUser() {

		return user;
	}

	/**
	 * @return 权限列表
	 */
	public Set<String> getAuths() {

		return auths;
	}

	/**
	 * 是否包含权限
	 * 
	 * @param auth 权限
	 * @return 是否
	 */
	public boolean has(String auth) {

		return auths.contains(auth);
	}
}
